﻿#include "stdafx.h"
#include "groupboxskin.h"

IMPLEMENT_SERIAL(CGroupBoxSkin,CObjectSkin,1)

CGroupBoxSkin::CGroupBoxSkin(const char* strNmae)
:CObjectSkin(strNmae,keGroupBoxSkin)
{
	m_fontGroupBox = GetDefaultFont();
	m_bAutoFont = TRUE; 
	m_colorCaption = GetSysColor(COLOR_BTNFACE);
}

CGroupBoxSkin::~CGroupBoxSkin(void)
{
}

const TCHAR * CGroupBoxSkin::GetDefaultSkinName()
{
	static const TCHAR NAME[] = _T("GroupBox");
	return NAME;
}

BOOL CGroupBoxSkin::DrawFrame( CDC *pDC, const CRect& rtDest )
{
	return DrawImageBorder(pDC,rtDest,m_imageFrame);
}

BOOL CGroupBoxSkin::DrawCaption( CDC *pDC, const CRect& rtDest )
{
	return DrawImageSection(pDC,rtDest,m_imageCaption);
}

void CGroupBoxSkin::Serialize(CArchive &ar)
{
	CObjectSkin::Serialize(ar);
	if(ar.IsStoring())
	{
		ar.Write(&m_fontGroupBox,sizeof(m_fontGroupBox));
		ar.Write(&m_bAutoFont,sizeof(m_bAutoFont));
		ar.Write(&m_imageFrame,sizeof(m_imageFrame));
		ar.Write(&m_imageCaption,sizeof(m_imageCaption));
		ar.Write(&m_colorCaption,sizeof(m_colorCaption));
		ar.Write(&m_textEffect,sizeof(m_textEffect));
	}
	else
	{
		ar.Read(&m_fontGroupBox,sizeof(m_fontGroupBox));
		ar.Read(&m_bAutoFont,sizeof(m_bAutoFont));
		ar.Read(&m_imageFrame,sizeof(m_imageFrame));
		ar.Read(&m_imageCaption,sizeof(m_imageCaption));
		ar.Read(&m_colorCaption,sizeof(m_colorCaption));
		ar.Read(&m_textEffect,sizeof(m_textEffect));
	}
}